package com.goldplusgold.tradedelay.app.my.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.goldplusgold.support.lib.base.activity.BaseActivity;
import com.goldplusgold.support.lib.utils.FragmentManagerUtil;
import com.goldplusgold.support.lib.hybird.WebViewFragment;
import com.goldplusgold.tradedelay.app.my.fragment.UserWebViewFragment;

/**
 * Created by Administrator on 2017/5/23.
 */

public class UserWebviewActivity extends BaseActivity {
    WebViewFragment webViewFragment;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        if (intent != null && intent.hasExtra("url")) {
            String url = getIntent().getStringExtra("url");
            switchFragment(url);
        }
    }

    private void switchFragment(String url) {
        webViewFragment = UserWebViewFragment.newInstance(url);
        FragmentManagerUtil.getInstance().openFragment(this, webViewFragment);
    }


    @Override
    public void onBackPressed() {
        if (webViewFragment != null) {
            webViewFragment.goBack();
        } else {
            super.onBackPressed();
        }
    }
}
